package main

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

func main() {
	// make gin not output logs to screen
	r := gin.New()
	r.Use(gin.Recovery())
	r.GET("/test_gin", func(c *gin.Context) {
		a := fib3(5150)
		c.JSON(http.StatusOK, gin.H{
			"code":    0,
			"message": "ok",
			"data":    a[:200],
		})
	})

	gin.SetMode(gin.ReleaseMode)
	// Listen and serve on 0.0.0.0:8080
	_ = r.Run(":8082")
}

func fib3(n int) []int {
	if n < 1 {
		return nil
	}
	lib_seq := []int{1, 1}
	if n <= 2 {
		return lib_seq[:n-1]
	}
	for i := 0; i < n-2; i++ {
		l := len(lib_seq)
		lib_seq = append(lib_seq, lib_seq[l-1]+lib_seq[l-2])
	}
	return lib_seq
}
